package com.ruoyi.mes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mes.domain.PlnReleasedPlan;
import com.ruoyi.mes.service.IPlnReleasedPlanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 计划订单联系Controller
 * 
 * @author ruoyi
 * @date 2024-06-04
 */
@RestController
@RequestMapping("/mes/released")
public class PlnReleasedPlanController extends BaseController
{
    @Autowired
    private IPlnReleasedPlanService plnReleasedPlanService;

    /**
     * 查询计划订单联系列表
     */
    @PreAuthorize("@ss.hasPermi('mes:released:list')")
    @GetMapping("/list")
    public TableDataInfo list(PlnReleasedPlan plnReleasedPlan)
    {
        startPage();
        List<PlnReleasedPlan> list = plnReleasedPlanService.selectPlnReleasedPlanList(plnReleasedPlan);
        return getDataTable(list);
    }

    /**
     * 导出计划订单联系列表
     */
    @PreAuthorize("@ss.hasPermi('mes:released:export')")
    @Log(title = "计划订单联系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlnReleasedPlan plnReleasedPlan)
    {
        List<PlnReleasedPlan> list = plnReleasedPlanService.selectPlnReleasedPlanList(plnReleasedPlan);
        ExcelUtil<PlnReleasedPlan> util = new ExcelUtil<PlnReleasedPlan>(PlnReleasedPlan.class);
        util.exportExcel(response, list, "计划订单联系数据");
    }

    /**
     * 获取计划订单联系详细信息
     */
    @PreAuthorize("@ss.hasPermi('mes:released:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(plnReleasedPlanService.selectPlnReleasedPlanById(id));
    }

    /**
     * 新增计划订单联系
     */
    @PreAuthorize("@ss.hasPermi('mes:released:add')")
    @Log(title = "计划订单联系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlnReleasedPlan plnReleasedPlan)
    {
        return toAjax(plnReleasedPlanService.insertPlnReleasedPlan(plnReleasedPlan));
    }

    /**
     * 修改计划订单联系
     */
    @PreAuthorize("@ss.hasPermi('mes:released:edit')")
    @Log(title = "计划订单联系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlnReleasedPlan plnReleasedPlan)
    {
        return toAjax(plnReleasedPlanService.updatePlnReleasedPlan(plnReleasedPlan));
    }

    /**
     * 删除计划订单联系
     */
    @PreAuthorize("@ss.hasPermi('mes:released:remove')")
    @Log(title = "计划订单联系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(plnReleasedPlanService.deletePlnReleasedPlanByIds(ids));
    }
}
